package com.ln.cmsln.controller.wei;


import com.ln.cmsln.pojo.entity.wei.Synopsis;
import com.ln.cmsln.service.wei.SynopsisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 魏存文
 * @since 2022-03-31
 */
@Api(tags = "企业荣誉")
@RestController
@RequestMapping("/api/synopsis")
@CrossOrigin
public class SynopsisController {
    @Resource
    private SynopsisService synopsisService;

    @ApiOperation("企业荣誉数据")
    @GetMapping("/list")
    public Object list(){
        List<Synopsis> list = synopsisService.list();
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("message", "请求数据成功");
        map.put("data", list);
        return map;
    }

    @ApiOperation("新增企业荣誉数据")
    @PostMapping("/save")
    public boolean save(
            @ApiParam(value = "企业荣誉数据",required = true)
            Synopsis synopsis
    ){
        return synopsisService.save(synopsis);
    }

    @ApiOperation("删除企业荣誉数据")
    @PostMapping("/delete")
    public boolean deleteById(
            @ApiParam(value = "企业荣誉id") Long id
    ){
        return synopsisService.removeById(id);
    }
}

